layui.define(['form', 'laydate', 'table'], function (exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var medicalCareTable = null;
    var view = {
        init: function () {
            this.initTable();
            this.initSearchForm();
            this.initToolBar();
            window.dataReload = function () {
                Lib.doSearchForm($("#searchForm"), medicalCareTable)
            }
        },
        initTable: function () {
            medicalCareTable = table.render({
                elem: '#medicalCareTable',
                height: Lib.getTableHeight(1),
                cellMinWidth: 100,
                method: 'post',
                url: Common.ctxPath + '/cms/medicalCare/Acceptancelist.json' // 数据接口
                , page: Lib.tablePage // 开启分页
                , limit: 10,
                cols: [[ // 表头
                    {
                        type: 'checkbox',
                        fixed: 'left',
                    },
                    {

                        field: 'medicalInstitutionText',
                        title: '定点医疗机构',
                        align: 'center',
                        width: "165"
                    },
                    {

                        field: 'spousenName',
                        title: '配偶姓名',
                        align: 'center',
                        width: "80"
                    },
                    {

                        field: 'spouseNumber',
                        title: '配偶证件号码',
                        align: 'center',
                        width: "80"
                    },
                    {

                        field: 'applicationTime',
                        title: '申请时间',
                        align: 'center',
                        width: "135"
                    },
                    {

                        field: 'serviceEndTime',
                        title: '服务结束时间',
                        align: 'center',
                        width: "180"
                    },
                    {

                        field: 'creationDate',
                        title: '创建日期',
                        align: 'center',
                        width: "180"
                    }

                ]]

            });

            table.on('checkbox(medicalCareTable)', function (obj) {
                var medicalCare = obj.data;
                if (obj.checked) {
                    //按钮逻辑Lib.buttonEnable()
                } else {

                }
            })
        },

        initSearchForm: function () {
            Lib.initSearchForm($("#searchForm"), medicalCareTable, form);
        },
        initToolBar: function () {
            toolbar = {
                find: function () { // 获取选中数目
                    var data = Common.getOneFromTable(table, "medicalCareTable");
                    if (data == null) {
                        return;
                    }
                    var url = "/cms/medicalCare/findenterprise.do?id=" + data.id;
                    Common.openDlg(url, "产业人才管理>查看");
                }
                ,
                process: function () { // 获取选中数目
                    var businessType = Common.businessType.medicalCare;
                    var data = Common.getOneFromTable(table, "medicalCareTable");
                    if (data == null) {
                        return;
                    }
                    var url = "/cms/businessProcess/index.do?businessType=" + businessType + "&businessId=" + data.id;
                    Common.openDlg(url, "流程信息>编辑");
                },
                acceptance: function () { // 获取选中数目
                    var data = Common.UnableToFirstTrial(table, "medicalCareTable");
                    if (data == null) {
                        return;
                    }
                    var url = "/cms/medicalCare/acceptance.do?id=" + data.id;
                    Common.openDlg(url, "产业人才管理>受理");
                }
            };
            $('.ext-toolbar').on('click', function () {
                var type = $(this).data('type');
                toolbar[type] ? toolbar[type].call(this) : '';
            });
        }
    }
    exports('enterpriseindex', view);

});